package com.mc.tcp;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;

public class ChannelServer {
	public void channelServer(){
		try {
			ServerSocketChannel ss = ServerSocketChannel.open();
			ss.bind(new InetSocketAddress("localhost",10000));
			ByteBuffer bb = ByteBuffer.allocate(100);
			bb.clear();
			SocketChannel sc = ss.accept();
			sc.read(bb);
			System.out.println(new String(bb.array()));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public static void main(String[] args) {
		ChannelServer cs = new ChannelServer();
		cs.channelServer();
	}
}
